﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZX.TR.Library;

namespace ZX.TR.Bussiness
{
    /// <summary>
    /// 调研题目信息类
    /// </summary>
    public class BTrSubjectInfo : BLL.Extend.BaseBussnies
    {
        /// <summary>
        /// 根据问卷ID获取所有题目列表
        /// </summary>
        /// <param name="TrQuestionnaireID">问卷ID</param>
        /// <returns>列表集合</returns>
        public IList<V_SubjectList> GetSubjectListByQuestionnaireID(Guid TrQuestionnaireID)
        {
            return this.GetEntitysBySqlComm<V_SubjectList>("select * from V_SubjectList where TrQuestionnaireID='" + TrQuestionnaireID + "' order by Sequence asc");
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="IndagateID">调研ID</param>
        /// <returns>列表集合</returns>
        public IList<TrIndagateSubject> GetListIndagateSubjectByIndagateID(Guid IndagateID)
        {
            return this.GetEntitysBySqlComm<TrIndagateSubject>("select * from TrIndagateSubject where TrIndagateID='" + IndagateID + "' order by Sequence asc");
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="IndagateID">调研ID</param>
        /// <returns>列表集合</returns>
        public IList<V_TrIndagateSubject> GetVListIndagateSubjectByIndagateID(Guid IndagateID)
        {
            return this.GetEntitysBySqlComm<V_TrIndagateSubject>("select * from V_TrIndagateSubject where TrIndagateID='" + IndagateID + "' order by Sequence asc");
        }
        /// <summary>
        /// 根据调研ID获取调研相关信息
        /// </summary>
        /// <param name="IndagateID">调研ID</param>
        /// <returns>实体对象</returns>
        public V_IndagateList GetIndagateByIndagateID(Guid IndagateID)
        {
            this.entity = new V_IndagateList();
            return this.GetEntityBySqlComm("select * from V_IndagateList where TrIndagateID='" + IndagateID + "'") as V_IndagateList;
        }
        /// <summary>
        /// 根据活动ID获取调研信息对比
        /// </summary>
        /// <param name="ActivityID">活动ID</param>
        /// <returns>列表集合</returns>
        public IList<V_IndagateList> GetIndagateByActivityID(Guid ActivityID)
        {
            this.entity = new V_IndagateList();
            return this.GetEntitysBySqlComm<V_IndagateList>("select * from V_IndagateList where TrActivityID='" + ActivityID + "'");
        }
        /// <summary>
        /// 判断活动中是否已存在(课前、课后)调研
        /// </summary>
        /// <param name="ActivityID">活动ID</param>
        /// <param name="strType">调研类型</param>
        /// <returns>true:已存在 false:不存在</returns>
        public bool GetIsExist(Guid ActivityID, string strType)
        {
            this.entity = new TrIndagate();
            return this.GetEntityByCondition("TrActivityID='" + ActivityID + "' and IndagateType='" + strType + "'") != null;
        }
        /// <summary>
        /// 判断活动中是否已存在(课前、课后)调研
        /// </summary>
        /// <param name="ActivityID">活动ID</param>
        /// <param name="strType">调研类型</param>
        /// <returns>true:已存在 false:不存在</returns>
        public TrIndagate GetIndagateCountsByActivityIDAndType(Guid ActivityID, string strType)
        {
            this.entity = new TrIndagate();
            return this.GetEntityBySqlComm<TrIndagate>("select * from TrIndagate where TrActivityID='" + ActivityID + "' and IndagateType='" + strType + "'");
        }
        /// <summary>
        /// 判断问卷是否存在
        /// </summary>
        /// <param name="QuestionnaireName">问卷名称</param>
        /// <returns>true:已存在 false:不存在</returns>
        public bool IsQuestionnaireExists(string QuestionnaireName)
        {
            this.entity = new TrQuestionnaire();
            return GetEntityByCondition("QuestionnaireName='" + QuestionnaireName + "'") != null;
        }
        /// <summary>
        /// 判断题目名称是否已存在
        /// </summary>
        /// <param name="SubjectName">题目名称</param>
        /// <returns>true:已存在 false:不存在</returns>
        public bool IsSubjectNameExists(string SubjectName)
        {
            this.entity = new TrSubjectInfo();
            return GetEntityByCondition("SubjectName='" + SubjectName + "'") != null;
        }

    }
}
